import { ApiCall } from "tsrpc";
import { ReqSearchSchools, ResSearchSchools } from "../../shared/protocols/Search/PtlSearchSchools";
import { Global } from "../../Global";

export default async function (call: ApiCall<ReqSearchSchools, ResSearchSchools>) {
    // TODO
    const name = call.req.name

    const schools = await Global.collection('schools').find({
        name:{
            $regex: new RegExp(name)
        }
    }).toArray()
    call.succ({
        schools: schools.map(i => {
            return i.name
        })
    })
}